from django.db import models

# Create your models here.
class Machines(models.Model):
    
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    ip = models.CharField(max_length=32)
    cpu = models.SmallIntegerField()
    mem = models.SmallIntegerField()
    disk = models.SmallIntegerField()
    state = models.SmallIntegerField()
    user = models.CharField(max_length=32)
    
    def __str__(self):
        return '%d:%s:%s'%(self.id,self.name,self.ip)
        
    class Meta:
        db_table = 'machines'
    
class MachinesUsage(models.Model):
    
    id = models.AutoField(primary_key=True)
    m_id = models.SmallIntegerField()
    m_ip = models.CharField(max_length=32)
    m_name = models.CharField(max_length=32)
    cpu_usage_rate = models.FloatField()
    mem_usage_rate = models.FloatField()
    disk_usasge_rate = models.FloatField()
    m_time = models.DateTimeField()
    
    def __str__(self):
        return '%d:%s:%s'%(self.id,self.m_name,self.m_ip)
        
    class Meta:
        db_table = 'machines_usage'

class Users(models.Model):
    
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    password = models.CharField(max_length=250)
    
    def __str__(self):
        return '%d:%s'%(self.id,self.name)
        
    class Meta:
        db_table = 'users'
